package com.doctcloud.hisinfo.histable.domain.comm;

import com.baomidou.mybatisplus.annotation.TableName;
import com.doctcloud.common.core.annotation.Excel;
import com.doctcloud.common.core.annotation.NotZero;
import com.doctcloud.common.core.annotation.TableDesc;
import lombok.*;
import org.apache.poi.ss.formula.eval.UnaryMinusEval;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

import static com.doctcloud.common.core.utils.StringUtils.extractChineseCharacters;
import static com.doctcloud.common.core.utils.StringUtils.trim;

@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(of = {"drugCode","drugSpec","drugIndicator"})
@ToString
@TableDesc("药品通用字典")
public class DrugDictDo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Excel(name = "药品通用名代码")
    @NotBlank(message = "药品通用名代码不得为空")
    private String drugCode;
    @Excel(name = "药品名称")
    @NotBlank(message = "药品名称不得为空")
    private String drugName;
    @Excel(name = "药品规格")
    @NotBlank(message = "药品规格不得为空")
    private String drugSpec;
    @Excel(name = "药品单位")
    private String units;
    @Excel(name = "药品剂型")
    private String drugForm;
    @Excel(name = "毒理属性")
    private String toxiProperty;
    @Excel(name = "最小单位剂量")
    @NotZero(message = "最小单位剂量不得为空")
    private Double dosePerUnit;
    @Excel(name = "剂量单位")
    @NotBlank(message = "剂量单位不得为空")
    private String doseUnits;
    @Excel(name = "药品类别")
    @NotNull(message = "药品类别不得为空")
    private String drugIndicator;
    @Excel(name = "输入码")
    private String inputCode;
    @Excel(name = "创建时间")
    private Date createTime;
    @Excel(name = "创建人员")
    private String createOperator;
    @Excel(name = "更新时间")
    private Date updateTime;
    @Excel(name = "更新人员")
    private String updateOperator;

    @Data
    public static class primaryKey {
        private final String drugCode;
        private final String drugSpec;
        private final Integer drugIndicator;
        public primaryKey(String drugCode, String drugSpec, Integer drugIndicator) {
            this.drugCode = drugCode;
            this.drugSpec = drugSpec;
            this.drugIndicator = drugIndicator;
        }
    }

    public void setDrugCode(String drugCode) {
        this.drugCode = trim(drugCode);
    }

    public void setDrugName(String drugName) {
        this.drugName = extractChineseCharacters(trim(drugName));
    }

    public void setDrugSpec(String drugSpec) {
        this.drugSpec = trim(drugSpec);
    }

    public void setUnits(String units) {
        this.units = trim(units);
    }

    public void setDoseUnits(String doseUnits) {
        this.doseUnits = trim(doseUnits);
    }

    public void setInputCode(String inputCode) {
        this.inputCode = trim(inputCode);
    }
}
